using System;
using System.Collections.Generic;
using Microsoft.Practices.RepositoryFactory.CodeGeneration.ObjectModel;
using NUnit.Framework;

namespace Microsoft.Practices.RepositoryFactory.Tests.CodeGeneration.ObjectModel
{
    [TestFixture]
    public class EntityHelperFixture
    {
        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void GetDebuggerDisplay_WithNullEntity()
        {
            EntityHelper.GetDebuggerDisplay(null);
        }

        [Test]
        public void GetDebuggerDisplay_WithSinglePrimaryKey()
        {
            Entity entity = new Entity();
            entity.Properties = new List<Property>();

            Property property = new Property();
            property.Name = "PK1";
            property.IsPrimaryKey = true;
            entity.Properties.Add(property);

            string result = EntityHelper.GetDebuggerDisplay(entity);
            Assert.AreEqual("PK1 = {PK1}", result);
        }

        [Test]
        public void GetDebuggerDisplay_WithCompositePrimaryKey()
        {
            Entity entity = new Entity();
            entity.Properties = new List<Property>();

            Property property = new Property();
            property.Name = "PK1";
            property.IsPrimaryKey = true;
            entity.Properties.Add(property);

            Property property2 = new Property();
            property2.Name = "PK2";
            property2.IsPrimaryKey = true;
            entity.Properties.Add(property2);

            string result = EntityHelper.GetDebuggerDisplay(entity);
            Assert.AreEqual("PK1 = {PK1}, PK2 = {PK2}", result);
        }

    }
}

